/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao.db;

import java.io.Serializable;
import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.jili.ubert.code.CodeTool;
import java.io.IOException;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dragon
 */
@Entity
@Table(name = "obj_classcode")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ObjClassCode.findAll", query = "SELECT o FROM ObjClassCode o"),
    @NamedQuery(name = "ObjClassCode.findByClassCode", query = "SELECT o FROM ObjClassCode o WHERE o.classCode = :classCode"),
    @NamedQuery(name = "ObjClassCode.findByUnderlyingCode", query = "SELECT o FROM ObjClassCode o WHERE o.underlyingCode = :underlyingCode"),
    @NamedQuery(name = "ObjClassCode.findByClassName", query = "SELECT o FROM ObjClassCode o WHERE o.className = :className"),
    @NamedQuery(name = "ObjClassCode.findByReMark", query = "SELECT o FROM ObjClassCode o WHERE o.reMark = :reMark"),
    @NamedQuery(name = "ObjClassCode.findByAlterUserID", query = "SELECT o FROM ObjClassCode o WHERE o.alterUserID = :alterUserID"),
    @NamedQuery(name = "ObjClassCode.findByCreateTime", query = "SELECT o FROM ObjClassCode o WHERE o.createTime = :createTime"),
    @NamedQuery(name = "ObjClassCode.findByTimeStamp", query = "SELECT o FROM ObjClassCode o WHERE o.timeStamp = :timeStamp")})
public class ObjClassCode implements Serializable {
	public static byte[] EnCode(ObjClassCode msg) throws IOException {
		Codec<ObjClassCode> Lcode = ProtobufProxy.create(ObjClassCode.class);
		return Lcode.encode(msg);
	}
	public static ObjClassCode DeCode(byte[] data) throws IOException {
	Codec<ObjClassCode> Lcode = ProtobufProxy.create(ObjClassCode.class);
		return Lcode.decode(data);
	}

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ClassCode")
    @Protobuf
	private String classCode;
    @Basic(optional = false)
    @Column(name = "UnderlyingCode")
    @Protobuf
	private String underlyingCode;
    @Basic(optional = false)
    @Column(name = "ClassName")
    private String className;
	@Protobuf
	private byte[] classNameBit;
    @Column(name = "ReMark")
    private String reMark;
	@Protobuf
	private byte[] reMarkBit;
    @Column(name = "AlterUserID")
    @Protobuf
	private String alterUserID;
    @Column(name = "CreateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
	//@Protobuf
//tprivate long createTimeL;
    @Column(name = "TimeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
	//@Protobuf
	//private long timeStampL;

    public ObjClassCode() {
    }

    public ObjClassCode(String classCode) {
        this.classCode = classCode;
    }

    public ObjClassCode(String classCode, String underlyingCode, String className) {
        this.classCode = classCode;
        this.underlyingCode = underlyingCode;
        this.className = className;
		this.classNameBit = CodeTool.StringToBit(className);
    }

    public String getClassCode() {
        return classCode;
    }

    public void setClassCode(String classCode) {
        this.classCode = classCode;
    }

    public String getUnderlyingCode() {
        return underlyingCode;
    }

    public void setUnderlyingCode(String underlyingCode) {
        this.underlyingCode = underlyingCode;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
        this.setClassNameBit(CodeTool.StringToBit(className));
    }

    public String getReMark() {
        return reMark;
    }

    public void setReMark(String reMark) {
        this.reMark = reMark;
		this.setReMarkBit(CodeTool.StringToBit(reMark));
    }

    public String getAlterUserID() {
        return alterUserID;
    }

    public void setAlterUserID(String alterUserID) {
        this.alterUserID = alterUserID;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
		//this.createTimeL = CodeTool.DateToLong(createTime);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
		//this.timeStampL = CodeTool.DateToLong(timeStamp);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (classCode != null ? classCode.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ObjClassCode)) {
            return false;
        }
        ObjClassCode other = (ObjClassCode) object;
        if ((this.classCode == null && other.classCode != null) || (this.classCode != null && !this.classCode.equals(other.classCode))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jili.ubert.dao.db.ObjClassCode[ classCode=" + classCode + " ]";
    }

    public byte[] getClassNameBit() {
        return classNameBit;
    }

    public void setClassNameBit(byte[] classNameBit) {
        this.classNameBit = classNameBit;
		this.className = CodeTool.BitToString(classNameBit);
    }

    public byte[] getReMarkBit() {
        return reMarkBit;
    }

    public void setReMarkBit(byte[] reMarkBit) {
        this.reMarkBit = reMarkBit;
		this.reMark = CodeTool.BitToString(reMarkBit);
    }
    
}
